//@zedd 
//@zedd 
$(document).ready(function(){
//index search
$("#search_index").click(function(){
	$("#searchBox").slideToggle(300);
});
//imgs slider
	 number = 0;
	$(".icon_slideshow").swipe({	
	swipeLeft:function(){
	var imgs_num=$(this).find(".img_list  a img").length-1;
	if(number<imgs_num){		
		number++;
		$(this).find(".img_list").animate({left: "-"+number*320+"px" }, 500);
		$(this).find(".icon_list span").css("background-color","#FFF");
		$(this).find(".icon_list").find("span:nth-child("+(number+1)+")").css("background-color","#fb8d13");
	}
	},
	swipeRight:function(){
		if(number>0){
			number--;
			$(this).find(".img_list").animate({left: "-"+number*320+"px" }, 500);
			$(this).find(".icon_list span").css("background-color","#FFF");
			$(this).find(".icon_list").find("span:nth-child("+(number+1)+")").css("background-color","#fb8d13");
		}
	}
	});

	setInterval(function(){
		number=number+1;
		if(number<= $(".icon_slideshow .img_list  a img").length-1){
		$(".img_list").animate({left:-320*number+"px"},500);
		}
		else{
		number=0
		$(".img_list").animate({left:-320*number+"px"},500);
		}
		$(".icon_slideshow .icon_list span").css("background-color","#FFF");
	    $(".icon_slideshow .icon_list").find("span:nth-child("+(number+1)+")").css("background","#fb8d13");
	},3000);	

	$(".icon_slideshow .icon_list span").click(function(){
		$(this).parents(".icon_slideshow").find(".img_list").animate({left: "-"+320*$(this).index()+"px" }, 500);
		$(this).parents(".icon_slideshow").find(".icon_list span").css("background-color","#FFF");
		$(this).css("background-color","#fb8d13");
	
	});
//dot slider
	woo_number = 0;
	$(".dot_slider").swipe({
		swipeLeft:function(){
		if(woo_number<$(".woo_slideshow .item_group").length-1||woo_number<$(".dot_slider .iconList").length-1){
			woo_number++;
			$(this).find(".dot_slider_con").animate({left: "-"+woo_number*320+"px" }, 500);
		    $(this).find(".dot_slider_icon span").css({"background":"#fff","border":"solid 1px #d7d6d6"});
			$(this).find(".dot_slider_icon").find("span:nth-child("+(woo_number+1)+")").css({"background":"#ff6600","border":"none"});
		}	
		/*else{
			woo_number=0;
			$(this).find(".dot_slider_con").animate({left: "-"+woo_number*320+"px" }, 500);
		    $(this).find(".dot_slider_icon span").css({"background":"#fff","border":"solid 1px #d7d6d6"});
			$(this).find(".dot_slider_icon").find("span:nth-child("+(woo_number+1)+")").css({"background":"#ff6600","border":"none"});
		}*/
	},
	swipeRight:function(){
		if(woo_number>0){
			woo_number--;
			$(this).find(".dot_slider_con").animate({left: "-"+woo_number*320+"px" }, 500);
			$(this).find(".dot_slider_icon span").css({"background":"#fff","border":"solid 1px #d7d6d6"});
			$(this).find(".dot_slider_icon").find("span:nth-child("+(woo_number+1)+")").css({"background":"#ff6600","border":"none"});
		}
	}
	});
	
	$(".woo_right").click(function(){ 
		if(woo_number==0){
		$(".dot_slider_con").animate({left: "-"+320+"px" }, 500);
		woo_number++;
		} 
	});
	$(".woo_left").click(function(){ 
		if(woo_number!=0){
		$(".dot_slider_con").animate({left: 0+"px" }, 500);
		woo_number--;
		} 
	});
//tab slider		
	tab_number = 0;
	$(".tab_slider .tab_slider_con").swipe({
		swipeLeft:function(){
		var group_num=$(this).find(".app_group").length;
		if(tab_number<group_num-1){
			tab_number++;
			$(".tab_slider_con").animate({left: "-"+tab_number*320+"px" }, 500);
			$(".tab_slider_tab li").removeClass();
			$(".tab_slider_tab").find("li:nth-child("+(tab_number+1)+")").addClass("now");
			if(tab_number>3){
			$(".tab_slider_tab").animate({left: -170+"px" }, 500);
			}
		}
	},
	swipeRight:function(){
		if(tab_number>0){
			tab_number--;
			$(".tab_slider_con").animate({left: "-"+tab_number*320+"px" }, 500);
			$(".tab_slider_tab li").removeClass();
			$(".tab_slider_tab").find("li:nth-child("+(tab_number+1)+")").addClass("now");
			if(tab_number<3){
			$(".tab_slider_tab").animate({left: 0+"px" }, 500);
			}
		}
	}
	});
	
	$(".tab_slider_tab li").click(function(){
	  if($(this).index()>3){
		$(".tab_slider_tab").animate({left: -120+"px" }, 500);
	  }
	  else{
		$(".tab_slider_tab").animate({left: 0+"px" }, 500);
	  }
		$(".tab_slider_con").animate({left: "-"+320*$(this).index()+"px" }, 500);
		$(".tab_slider_tab li").removeClass();
		$(this).addClass("now");	
	
	});
	
	//tab busin
	$(".tab_slider_tab2 li").click(function(){
		$(".tab_slider_con2").animate({left: "-"+320*$(this).index()+"px" }, 500);
		$(".tab_slider_tab2 li").removeClass();
		$(this).addClass("now");	
	
	});
	
//txt imgs slider	
	var text_number = 0;
	var text_num=$(this).find(".text_slideshow_item").length-1;
	$(".text_slideshow").swipe({
	swipeLeft:function(){
		var text_num=$(this).find(".text_slideshow_item").length-1;
		if(text_number<text_num){
			text_number++;
			$(this).find(".text_slideshow_group").animate({left: "-"+text_number*320+"px" }, 500);
		}
	},
	swipeRight:function(){
	 
		if(text_number>0){
			text_number--;
			$(this).find(".text_slideshow_group").animate({left: "-"+text_number*320+"px" }, 500);
		}
	}
	});
	
	$(".text_slideshow .slideshow_text_left").click(function(){
		if(text_number>0){
			text_number--;
			$(this).parents(".text_slideshow").find(".text_slideshow_group").animate({left: "-"+text_number*320+"px" }, 500);
		}
	});
	
	$(".text_slideshow .slideshow_text_right").click(function(){
		if(text_number<text_num){
			text_number++;
			$(this).parents(".text_slideshow").find(".text_slideshow_group").animate({left: "-"+text_number*320+"px" }, 500);
		}
		else{
			text_number=0;
		    $(this).parents(".text_slideshow").find(".text_slideshow_group").animate({left: "-"+text_number*320+"px" }, 500);
		}
	});
//arrow tab slider
	/*
	var h_height=0;
	$(document).ready(function(){
		jQuery(".arrow_slider_con").css("height",jQuery(".arrow_slider_con ul:first").height() + "px");
		h_height=jQuery(".arrow_slider_con ul:first").height();
	});
*/
	var at=0;
	$(".arrow_slider").swipe({	
	swipeLeft:function(){
	   // var group_num=$(this).find("ul").length;
		if(at<$(this).find("ul").length-1||at<$(this).find(".app_group").length-1){
			at++;
			$(this).find(".arrow_slider_con").animate({left: "-"+at*320+"px" }, 500);
			$(this).find("h3 span").removeClass("at");
			$(this).find("h3 span:nth-child("+(at+1)+")").addClass("at");
		}
       //height
		/*
		jQuery(".arrow_slider_con").css("height",jQuery(".arrow_slider_con ul").eq(at).height() + "px");
		*/
	},
	swipeRight:function(){
		if(at>0){
			at--;
			$(this).find(".arrow_slider_con").animate({left: "-"+at*320+"px" }, 500);
			$(this).find("h3 span").removeClass("at");
			$(this).find("h3 span:nth-child("+(at+1)+")").addClass("at");
		}
		//height
		/*jQuery(".arrow_slider_con").css("height",h_height + "px");*/
	}
	});
	
	$(".arrow_slider_tab span[class!='more']").click(function(){
		$(this).parents(".arrow_slider").find(".arrow_slider_con").animate({left: "-"+320*$(this).index()+"px" }, 500);
		$(this).parents(".arrow_slider").find(".arrow_slider_tab span[class!='more']").removeClass();
		$(this).addClass("at");	
	
	});
	
	//comment
	/*$(".comment_txtArea .btn3").click(function(){
		$(".pop_cover").show();
		$(".c_pop").show();
	});*/
	$(".c_pop .btn1").click(function(){
		$(".c_pop").hide();
		$(".pop_cover").hide();
	});
	//star
	var $star = $("#stars");
	var $li = $star.find("span");
	var iScore=0;
	$li.click(function()
	{
		var iStar = $(this).index();
		iScore = iStar;
		for (i = 0; i < $li.length; i++) 
		{
			if(i <= iScore){
				$li.eq(i).attr("class","redStar");
			}else{
				$li.eq(i).attr("class","grayStar");
			}
		}
	});
	//video list
	$(".moreShow").click(function(){
		$("#slide_nav").toggle();
	});
	//video info
	/*$("#collect").click(function(){
		$(".pop_cover").show();
		$(".c_pop").show();
		setTimeout(function(){
		$(".pop_cover").hide();
		$(".c_pop").hide();
		},3000)
	});*/
	//login
	/*setTimeout(function(){
		$(".pop_cover").hide();
		$(".c_pop").hide();
		},3000)*/
		
	$("#share").click(function(){
		$("#slide_nav").toggle();
	});
	//reg
	var code_n=60;
	mycount2=function(){
			if (parseInt(code_n) == 1) {
				$("#freeCode").html("免费获取验证码");
				code_n=60;
			} else {
				code_n = parseInt(code_n) - 1;
				$("#freeCode").html("<span style='color:red'> "+code_n+" </span>秒后可重新获取");
				setTimeout('mycount2()',1000);
			}
		};
	mycount4=function(){
		if (parseInt(code_n) == 1) {
			$("#orderfreeCode").html("免费获取验证码");
			code_n=60;
		} else {
			code_n = parseInt(code_n) - 1;
			$("#orderfreeCode").html("<span style='color:red'> "+code_n+" </span>秒后可重新获取");
			setTimeout('mycount4()',1000);
		}
	};
	/*$("#freeCode").click(function(){
		mycount2();
	}); */	
	//ckbox
	$(".ckbox span").click(function(){
		$(".ckbox span").removeClass("ck");
		$(this).addClass("ck");
	}); 
	$("#ckAll").click(function(){
		$("input[name='ck']").each(function(){
		   $(this).attr("checked","checked");
		});  
	});
	$("#ckOthers").click(function(){
		$("input[name='ck']").each(function(){
		 	$(this).attr("checked",!this.checked);              
        });
	});
	//info
	$(".arrow_d").click(function(){
		//$(".v_info p").css("height", $(".v_info p").height() == "65" ? "auto" : "65");
		//$(".v_info p").css("height", "auto");
		$(".v_info_pBox").css("height", $(".v_info p").height() == "65" ? "auto" : "65");	
		$(this).toggleClass("arrow_t");
		
	});
	//edit
	/*$(".edit").live("click",function(){
		var ct=$(this).parent().siblings();
		var tel=ct.find(".tel").html();
		var note=ct.find(".note").html();
		var tmp = "手机号：<input type='text' class='tel' value="+tel+"><br/>备注名：<input type='text' class='note' value="+note+">";
		ct.html(tmp);
		$(this).html("完成");
		$(this).attr("class","finish");
	});*/
	/*$(".finish").live("click",function(){
		var ct=$(this).parent().siblings();
		var tel=ct.find(".tel").val();
		var note=ct.find(".note").val();
		var tmp = "手机号：<span class='tel'>"+tel+"</span><br/>备注名：<span class='note'>"+note+"</span>";
		ct.html(tmp);
		$(this).html("修改");
		$(this).attr("class","edit");
	});*/
	/*$(".del").live("click",function(){
		var ct=$(this).parents("li");
		ct.remove();
	});*/
	//find psw
	/*var num = 60;
	myCount = function() {
		if (parseInt(num) == 1) {
			location.href="login.html";
		} else {
			num = parseInt(num) - 1;
			$("#count").html(num);
			setTimeout('myCount()',1000); 
		}
	}
	$("#findpsw").click(function(){
		$(".pop_cover").show();
		$(".c_pop").show();
		myCount();
	});*/
	
	
	
	//order
/*	$(".cancelOrder").click(function(){
		$(".pop_cover").show();
		$(".pop_win").show();
	});
	
	$(".pop_win .close,.cancel ").click(function(){
		$(".pop_cover").hide();
		$(".pop_win").hide();
	});
	
	$(".pop_win_tuiding .close,.cancel ").click(function(){
		$(".pop_cover").hide();
		$(".pop_win_tuiding").hide();
	});*/
	/*$(".pop_win .close,.pop_win .btn1").click(function(){
		$(".pop_cover").hide();
		$(".pop_win").hide();
	});*/
	
	//rule
	$(".g_ruleContent").hide().eq(0).show();
	$(".g_ruleItem h3").click(function(){
		$(".g_ruleContent").hide();
		$(".g_ruleArrrow").removeClass("g_ruleClose");
		$(this).parent().find(".g_ruleContent").show();
		$(this).find(".g_ruleArrrow ").addClass("g_ruleClose");
	});
	
});